package jobworker

import (
	"fmt"
	"gitee.com/captials-team/ubdframe/src/common/utils"
	"gitee.com/captials-team/ubdframe/src/domain/configstc"
	"gopkg.in/yaml.v3"
)

func NewJobConfig(s ...string) *configstc.JobConfig {
	var c configstc.JobConfig

	err := utils.ReadYamlFile(&c, configstc.DefiConfigPath(s...))
	if err != nil {
		panic(fmt.Sprintf("read config yaml: %s", err))
	}

	return &c
}

func ParseJobConfig(s string) *configstc.JobConfig {
	var c configstc.JobConfig
	yaml.Unmarshal([]byte(s), &c)
	return &c
}
